<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
        <title>授课班级管理</title>
        <include file='Layout:ins_css' />
        <style type="text/css">
            #addBtn {
                float: right;
                margin: -7px 6px 9px;
            }
            #setingBtn {
                float: right;
                margin: -7px 6px 9px;
            }
            .setting-col{
                margin: 5px 0 0 5px;
            }

        </style>
    </head>
    <body>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>授课班级管理</h5>
                            <button class="btn btn-info" id="addBtn">添加授课班</button>
                        </div>
                        <div class="row s-row">
                            <div class="col-sm-12">
                                <div class="price-div">
                                    <form class="form-horizontal">
                                        <div class="form-group cyf-form-group">
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left" class="col-sm-4 control-label cvbnm">教学方案: </label>
                                                <select class="form-control col-sm-" id="teach_method_id" name="teach_method_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="teachingmethod_info" id="vo">
                                                        <option value="{$vo.id}">{$vo.me_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left; margin-right: 13px;" class="col-sm-4 control-label cvbnm">状态: </label>
                                                <select class="form-control col-sm-" id="tc_status_id" name="tc_status_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <option value="1">通过</option>
                                                    <option value="2">等待审核</option>
                                                    <option value="3">未通过</option>
                                                    <option value="4">注销</option>
                                                </select>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <table class="table table-striped table-bordered table-hover dataTables-example" id="RuleTable">
                                <thead>
                                <tr>
                                    <th width="10%">授课班编号</th>
                                    <th width="20%">授课班名称</th>
                                    <th width="10%">教学方案</th>
                                    <th width="10%">起始时间</th>
                                    <th width="10%">结束时间</th>
                                    <th width="10%">状态</th>
                                    <th width="10%">人数</th>
                                    <th width="20%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Modal 新增编辑授课班-->
        <div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel"></h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" id="form_add">
                            <div class="form-group">
                                <label class="col-sm-3 control-label cvbm nationality">教学方案</label>
                                <select class="form-control poiu" id="tme_boss" name="tme_boss" style="min-height: 35px">
                                    <option value="0">全部</option>
                                    <volist name="teachingmethod_info" id="vo">
                                        <option value="{$vo.id}">{$vo.me_name}</option>
                                    </volist>
                                </select>
                            </div>
                            <div class="hidden">
                                <label class="col-sm-3 control-label">授课班编号</label>
                                <div class="col-sm-7">
                                    <input type="text" id="edit_teachingclass_id" name="edit_teachingclass_id" class="form-control removeData">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">授课班名称</label>
                                <div class="col-sm-7">
                                    <input type="text" id="teachingclass_name" name="teachingclass_name" class="form-control removeData">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label cvbm nationality">授课班类型</label>
                                <select class="form-control poiu" id="tctype" name="tctype" style="min-height: 35px">
                                    <option value="0">全部</option>
                                    <volist name="tctype_info" id="vo">
                                        <option value="{$vo.type_id}">{$vo.type_name}</option>
                                    </volist>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">授课教师</label>
                                <div class="col-sm-7">
                                    <input type="text" readonly="readonly" id="tea_name" name="tea_name" value="{$tea_name}" class="form-control removeData">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">开始日期</label>
                                <div class="col-sm-7">
                                    <input placeholder="开始日期" style="max-width: 305px" class="laydate-icon form-control layer-date removeData" id="start" name="start">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">结束日期</label>
                                <div class="col-sm-7">
                                    <input placeholder="结束日期" style="max-width: 305px" class="laydate-icon form-control layer-date removeData" id="end" name="end">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3  control-label " style="margin-top: 30px;">课程描述</label>
                                <div class="col-sm-7">
                                    <textarea name="teachingclass_intro" id="teachingclass_intro" class="form-control  cyf-inpput removeData" rows="" cols="" style="height: 100px;"></textarea>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="add_btn">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <!-- Modal 设置授课班-->
        <div class="modal fade" id="SettingeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="">设置授课班进度</h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" id="form_setting">
                            <div class="form-group">
                                 <div class="col-sm-6">
                                     <label class="col-sm-4 control-label">教学方案</label>
                                     <div class="col-sm-8 ">
                                         <input type="hidden" id="set_tme_id" name="set_tme_id">
                                         <input type="text" readonly="readonly" id="set_tme_name" name="set_tme_name" class="form-control removeData">
                                     </div>
                                 </div>
                                 <div class="col-sm-6">
                                    <label class="col-sm-4 control-label" style="padding-right: 0">授课班编号</label>
                                    <div class="col-sm-8">
                                        <input type="text" readonly="readonly" id="set_tc_id" name="set_tc_id" class="form-control removeData">
                                    </div>
                                 </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6">
                                    <label class="col-sm-4 control-label">开始日期</label>
                                    <div class="col-sm-8">
                                        <input placeholder="开始日期" readonly="readonly" class="laydate-icon form-control layer-date removeData" id="set_start" name="set_start">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-4 control-label">结束日期</label>
                                    <div class="col-sm-8">
                                        <input placeholder="结束日期" readonly="readonly" class="laydate-icon form-control layer-date removeData" id="set_end" name="set_end">
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="seting_btn">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <include file='Layout:ins_js' />
        <script src="__JS__/plugins/layer/laydate/laydate.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                check_index();
                //datatable
                sTable = $("#RuleTable").DataTable({
                    "fnServerParams": function (aoData) {
                        aoData.push({
                            'name': 'tme_id',
                            'value': $('select#teach_method_id option:selected').val(),
                        },{
                            'name': 'tc_status',
                            'value': $('select#tc_status_id option:selected').val()
                        });
                    },
                    "order": [[0, "asc"]],
                    //              "aaSorting": [
                    //                  [0, "asc"]
                    //              ],
                    "bAutoWidth": false,
                    "oLanguage": {
                        "sLengthMenu": "每页 _MENU_ ",
                        "sProcessing": "处理中...",
                        "sZeroRecords": "没有匹配结果",
                        "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                        "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                        "sInfoPostFix": "",
                        "sSearch": "搜索:",
                        "sUrl": "",
                        "sEmptyTable": "表中数据为空",
                        "sLoadingRecords": "载入中...",
                        "sInfoThousands": ",",
                        "oPaginate": {
                            "sFirst": "首页",
                            "sPrevious": "上页",
                            "sNext": "下页",
                            "sLast": "末页"
                        },
                        "oAria": {
                            "sSortAscending": ": 以升序排列此列",
                            "sSortDescending": ": 以降序排列此列"
                        }
                    },
                    "sAjaxSource": "__URL__/class_ShowDatatables", //调用php后台接口方法地址
                    "aoColumns": [{
                        'data'  : 'tc_id'
                    },{
                        'data'  : 'tc_name'
                    },{
                        'data': 'me_name'
                    },{
                        'data': 'tc_strdate'
                    },{
                        'data': 'tc_enddate'
                    },{
                        'data': 'tc_status'
                    },{
                        'data': 'tc_stunum'
                    },  {
                        "data": null,
                        orderable: false,
                        render: function (data, type, row, meta) {
                            return '<a type="button" class="btn btn-primary" href="#" onclick=SetDateIntervalFromID(this) >教学进度</a>|<a type="button" class="btn btn-success" href="#" onclick=editFromID(this) >编辑</a>|<a type="button" class="btn btn-danger" href="#" onclick=delFromID(this) >删除</a>'
                        }
                    }]
                });
                //日期范围限制
                var start = {
                    elem: '#start',
                    format: 'YYYY/MM/DD',
                    min: laydate.now(), //设定最小日期为当前日期
                    max: '2999-06-16 23:59:59', //最大日期
                    istime: false,
                    istoday: true,
                    choose: function (datas) {
                        end.min = datas; //开始日选好后，重置结束日的最小日期
                        end.start = datas //将结束日的初始值设定为开始日
                    }
                };
                var end = {
                    elem: '#end',
                    format: 'YYYY/MM/DD',
                    min: laydate.now(),
                    max: '2999-06-16 23:59:59',
                    istime: false,
                    istoday: true,
                    choose: function (datas) {
                        start.max = datas; //结束日选好后，重置开始日的最大日期
                    }
                };
                laydate(start);
                laydate(end);

                var set_start = {
                    elem: '#set_start',
                    format: 'YYYY/MM/DD',
                    min: laydate.now(), //设定最小日期为当前日期
                    max: '2999-06-16 23:59:59', //最大日期
                    istime: false,
                    istoday: true,
                    choose: function (datas) {
                        end.min = datas; //开始日选好后，重置结束日的最小日期
                        end.start = datas //将结束日的初始值设定为开始日
                    }
                };
                var set_end = {
                    elem: '#set_end',
                    format: 'YYYY/MM/DD',
                    min: laydate.now(),
                    max: '2999-06-16 23:59:59',
                    istime: false,
                    istoday: true,
                    choose: function (datas) {
                        start.max = datas; //结束日选好后，重置开始日的最大日期
                    }
                };
                laydate(set_start);
                laydate(set_end);

            });
            //查询
            $("select#teach_method_id").change(function(){
                sTable.ajax.reload();
            });
            $('select#tc_status_id').change(function () {
                sTable.ajax.reload();
            });
            /* ---------------------------------     新增 编辑 相关 ------------------------------------*/
            //新增
            $('#addBtn').on('click', function() {
                $('.wrapper').removeClass('animated');
                document.getElementById("myModalLabel").innerText = "新增授课班";
                $('#tea_name').val("{$tea_name}");
                $('#Modal').modal();
            });
            //编辑
            function editFromID(obj){
                document.getElementById("myModalLabel").innerText = "编辑授课班";
                $('Modal').modal();
            }


            $('#add_btn').on('click',function () {
                var formData = $('#form_add').serializeArray();
                var modal_title = $('#myModalLabel').text();
                var postData = {};
                $(formData).each(function(i) {
                    postData[this.name] = this.value;
                });
                if (modal_title.trim() == '新增授课班') {
                    sil_loading();
                    $.ajax({
                        type: "post",
                        url: "__URL__/add_teachingclass",
                        async: true,
                        data: postData,
                        dataType: 'json',
                        success: function(p) {
                            if(p.state) {
                                toastr.success(p.info);
                                $("#Modal").modal('hide');
                                sTable.ajax.reload();
                            } else {
                                toastr.warning(p.info);
                            }
                            sil_reloading();
                        }
                    });
                }else if(modal_title.trim() == '编辑授课班'){

                }else{

                }
            });













            function SetDateIntervalFromID(obj){
                $('.wrapper').removeClass('animated');
                $('#SettingeModal').modal();
            }
        </script>
    </body>
</html>